

//
//  ZYAddStrongCouseDetailTowCell.m
//  优学荟管理系统
//
//  Created by edz on 2017/11/27.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYAddStrongCouseDetailTowCell.h"
#import "ZYAddStrongCouseDetailTowModel.h"
@implementation ZYAddStrongCouseDetailTowCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    return self;
    
}

- (void)assignByZYAddStrongCouseDetailTowModel:(ZYAddStrongCouseDetailTowModel *)model{
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@",[model.setCourseComment valueForKey:@"content"]];
    self.countLabel.text = [NSString stringWithFormat:@"%@",model.commentCount];
    
    NSString *totleComment = [NSString stringWithFormat:@"%@",model.totleCommentCount];
    
    
    BOOL isUp = [NSString isBlankString:totleComment];
    
    if (isUp) {
        
        
        self.pView.progress = 0.0;
    }else{
        
        float mm = [model.commentCount doubleValue] /[model.totleCommentCount doubleValue];
        
        self.pView.progress = mm;
    }
    
    
    
}




- (void)setUpSuperView{
    
    self.nameLabel = [UILabel new];
    self.nameLabel.font = [UIFont systemFontOfSize:13];
    self.nameLabel.textColor = ColorRGB(153,153,153);
    self.nameLabel.numberOfLines = 0;
    [self.contentView addSubview:self.nameLabel];
    
    self.nameLabel.text = @"要素一:张宇";
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.offset(10);
        make.right.equalTo(self).offset(-(kScreenWidth - 100));
    }];
    
    
    self.pView = [UIProgressView new];
    self.pView.progressTintColor= [self randomColor];
    self.pView.trackTintColor = ColorRGB(237, 234, 235);
    self.pView.layer.cornerRadius = 5;
    self.pView.clipsToBounds = YES;
    [self.contentView addSubview:self.pView];
    
    
    
    
    
    [self.pView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.nameLabel.mas_right).offset(10);
        make.centerY.equalTo(self.nameLabel);
        make.height.offset(10);
        make.width.offset(kScreenWidth - 160);
        
        
    }];
    
    
    self.countLabel = [UILabel new];
    self.countLabel.font = [UIFont systemFontOfSize:13];
    self.countLabel.textColor = ColorRGB(145, 195, 247);
    self.countLabel.text = @"ddd";
    
    [self.contentView addSubview:self.countLabel];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.pView.mas_right).offset(10);
        make.centerY.equalTo(self.pView);
        
    }];
    
    
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(self.nameLabel).offset(10);
    }];
    
    
}


-(UIColor *) randomColor
{
    CGFloat hue = ( arc4random() % 256 / 256.0 );  //0.0 to 1.0
    CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5;  // 0.5 to 1.0,away from white
    CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5;  //0.5 to 1.0,away from black
    return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
    
}


@end
